<h1>Upload a New Torrent</h1>

<center>
	<%= render :partial => 'shared/notice_text', :locals => {:flash => flash} %>
	
	<div class="highlight" style="width: 600px;">Please use your personalized tracker URL when creating the torrent: <br/
		<div style="padding-top: 5px;"><i><b><%= current_user.tracker_url %></i></b></div>
	</div>
</center>
<%= form_tag({:controller => 'torrent', :action => 'upload' }, { :multipart => true, :id => 'upload-form' }) %>
	<center>
	<%= render :partial => 'shared/notice_text', :locals => {:flash => flash} %>
	<table cellspacing="2" cellpadding="2" width="500px" style="border: 1px dotted #ccc">
		<tr>
			<td><label for="torrent_file">Torrent file:</label></td>
			<td>
				<input type="file" name="the_torrent" class="required"/>
			</td>
		</tr>
		<tr>
			<td><label for="torrent_name">Torrent name:</label></td>
			<td>
				<%= text_field :torrent, :name, :size => 40, :maxlength => 90,	:class => '' %> <br/>
				<i>(taken from filename if not specified)</i>
			</td>
		</tr>
		<tr>
			<td><label for="torrent_category">Category:</label></td>
			<td>
				<input type="hidden" value="dummy" class="category-required-123">
				<%= select_tag("torrent[category_id]", "<option>(Select)</option>" + options_from_collection_for_select(@categories, :id, :name), :class => 'category-required') %>
			</td>
		</tr>
		<tr>
			<td><label for="torrent_description">Description:</label></td>
			<td>
				<%= text_area :torrent, :description, :style => 'width: 90%; height: 120px' %>
			</td>
		</tr>
		<tr>
			<td colspan="2">

				<%= hidden_field_tag 'user_id', current_user.id %>

				<div style="margin-left: 200px;"><input type="Submit" value="Upload It  &#187; " class="submit-box"><br/>
				</div>
			</td>
		</tr>
	</table>
	</center>
</form>

<script type="text/javascript">

	category_selected = function(value, element) {
		var idx = element.selectedIndex;
		if (0 == idx) {
			return false
		}
		return true;
	}
	Validation.add('category-required', 'Please select a category.', category_selected);

  new Validation('upload-form');
</script>

